package cn.hebutrun.oulabot.controller;


import cn.hebutrun.oulabot.common.Constants;
import cn.hebutrun.oulabot.common.util.ApiUtil;
import cn.hebutrun.oulabot.service.ITryService;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zhaolong
 * @since 2022-09-05
 */
@RestController
@RequestMapping("/try")
@RequiredArgsConstructor
public class TryController {

  private final ITryService iTryService;
  private final ApiUtil apiUtil;

  @GetMapping("/lunch")
  public String lunch(HttpServletRequest httpServletRequest) {
    return StrUtil.format(
        Constants.HTML_CONTENT_TEXT, iTryService.lunch(httpServletRequest.getRemoteAddr()));
  }

  @GetMapping
  public String goodMorning() {
    return apiUtil.goodAfternoon();
  }
}
